﻿namespace LeadMaster.DAL
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using LeadMaster.Models;
    using System.Data.Entity.ModelConfiguration.Conventions;
    using System.Data.Entity;
    using System.Data.Entity.ModelConfiguration;

    public class DunsmoreContext : DbContext
    {
        public DbSet<Leads> Leads { get; set; }
        public DbSet<Contacts> Contacts { get; set; }
        public DbSet<Companies> Companies { get; set; }
        public DbSet<DunsmoreUsers> DunsmoreUsers { get; set; }
        public DbSet<LeadHistory> LeadHistory { get; set; }
        public DbSet<LeadNotes> LeadNotes { get; set; }
        public DbSet<LeadSectorList> LeadSectorList { get; set; }
        public DbSet<LeadType> LeadType { get; set; }
        public DbSet<LeadStatuses> LeadStatuses { get; set; }
        public DbSet<NotePhrases> NotePhrases { get; set; }
        public DbSet<Receptive> Receptive { get; set; }
        public DbSet<Sectors> Sectors { get; set; }
        public DbSet<Diary> Diary { get; set; }
        public DbSet<ScheduleSection> ScheduleSection { get; set; }
        public DbSet<ScheduleTemplate> ScheduleTemplate { get; set; }
        public DbSet<ScheduleTemplateSection> ScheduleTemplateSection { get; set; }
        public DbSet<PaymentTerms> PaymentTerms { get; set; }
        public DbSet<Invoicing> Invoicing { get; set; }
        public DbSet<LeadsReplacement> LeadsReplacement { get; set; }
        public DbSet<FrameworkAgreements> FrameworkAgreements { get; set; }
        public DbSet<TermConditions> TermConditions { get; set; }
        public DbSet<SectionMerges>  SectionMerges { get; set; }
        public DbSet<Orders> Orders { get; set; }
        public DbSet<OrderStatus> OrderStatus { get; set; }
        public DbSet<OrderSections> OrderSections { get; set; }
        public DbSet<Fees> Fees { get; set; }
        public DbSet<Enquiries> Enquiry { get; set; }
        public DbSet<EnquiryTypes> EnquiryTypes { get; set; }
        public DbSet<TradingAddresses> TradingAddresses { get; set; }
        public DbSet<Salutations> Salutations { get; set; }
        public DbSet<Users> Users { get; set; }
		    public DbSet<CallCentres> CallCentres { get; set; }
		    public DbSet<LeadMonitor> LeadMonitor { get; set; }
        public DbSet<BoilerLeads> BoilerLeads { get; set; }
        public DbSet<LeadTemplate> LeadTemplate { get; set; }
        public DbSet<LeadStat> LeadStat { get; set; }
        public DbSet<LeadStatQuestions> LeadStatQuestions { get; set; }
        public DbSet<LeadGroups> LeadGroups { get; set; }
        public DbSet<LeadGroupQuestions> LeadGroupQuestions { get; set; }
        public DbSet<CompanyRegistered> CompanyRegistered { get; set; }
        public DbSet<CompanySundries> CompanySundries { get; set; }
        public DbSet<CompanyRestrictions> CompanyRestriction { get; set; }
        public DbSet<LeadResults> LeadResults { get; set; }
        public DbSet<ClientUsers> ClientUsers { get; set; }
        public DbSet<LeadReasons> LeadReasons { get; set; }
        public DbSet<LeadFlags> LeadFlags { get; set; }
        public DbSet<LeadStatus> LeadStatus { get; set; }
        public DbSet<PurchaseOrders> PurchaseOrders { get; set; }
        public DbSet<LoadingCapacity> LoadingCapacity { get; set; }
        public DbSet<Chasers> Chasers { get; set; }
        public DbSet<PostCodes> Postcodes { get; set; }
        public DbSet<NextRef> NextRef { get; set; }
        public DbSet<RefreshPO> RefreshPO { get; set; }
        public DbSet<UserFile> UserFile { get; set; }
        public DbSet<ReferralCats> ReferralCats { get; set; }
        public DbSet<ReferralData> ReferralData { get; set; }
        public DbSet<QCOrder> QCOrder { get; set; }
        public DbSet<ResetLockout> ResetLockout { get; set; }
        public DbSet<Surveys> Surveys { get; set; }
        public DbSet<SurveyMappings> SurveyMappings { get; set; }
        public DbSet<SurveyContacts> SurveyContacts { get; set; }
        public DbSet<SurveyCompletion> SurveyCompletion { get; set; }
        public DbSet<ExportMappings> ExportMappings { get; set; }
        public DbSet<Countries> Countries { get; set; }
        public DbSet<Counties> Counties { get; set; }
        public DbSet<ExportData> ExportData { get; set; }
        public DbSet<ExportDataHistory> ExportDataHistory { get; set; }
        public DbSet<SurveyConstraints> SurveyConstraints { get; set; }
        public DbSet<SSC> SSC { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
            modelBuilder.Entity<Companies>().HasKey(x => x.CompanyID);
            modelBuilder.Entity<Contacts>().HasKey(x => x.ContactID);
            modelBuilder.Entity<Contacts>().HasRequired(t => t.Company);
            modelBuilder.Entity<DunsmoreUsers>().HasKey(x => x.UserID);
            modelBuilder.Entity<LeadHistory>().HasKey(x => x.LeadHistoryID);
            modelBuilder.Entity<LeadNotes>().HasKey(x => x.LeadNotesID);
            modelBuilder.Entity<LeadSectorList>().HasKey(x => x.LeadSectorListID);
            modelBuilder.Entity<LeadType>().HasKey(x => x.LeadTypeID);
            modelBuilder.Entity<LeadStatuses>().HasKey(x => x.LeadStatusesID);
            modelBuilder.Entity<NotePhrases>().HasKey(x => x.NotePhraseID);
            modelBuilder.Entity<Receptive>().HasKey(x => x.ReceptiveID);
            modelBuilder.Entity<Sectors>().HasKey(x => x.SectorID);
            modelBuilder.Entity<Diary>().HasKey(x => x.DiaryID);
            modelBuilder.Entity<ScheduleSection>().HasKey(x => x.ScheduleSectionsID);
            modelBuilder.Entity<ScheduleTemplate>().HasKey(x => x.ScheduleTemplateID);
            modelBuilder.Entity<ScheduleTemplateSection>().HasKey(x => x.ScheduleTemplateSectionsID);
            modelBuilder.Entity<PaymentTerms>().HasKey(x => x.PaymentTermsID);
            modelBuilder.Entity<Invoicing>().HasKey(x => x.InvoicingID);
            modelBuilder.Entity<LeadsReplacement>().HasKey(x => x.LeadsReplacementID);
            modelBuilder.Entity<FrameworkAgreements>().HasKey(x => x.FrameworkAgreementID);
            modelBuilder.Entity<TermConditions>().HasKey(x => x.TermConditionsID);
            modelBuilder.Entity<SectionMerges>().HasKey(x => x.SectionMergesID);
            modelBuilder.Entity<Orders>().HasKey(x => x.OrderID);
            modelBuilder.Entity<OrderStatus>().HasKey(x => x.OrderStatusID);
            modelBuilder.Entity<OrderSections>().HasKey(x => x.OrderSectionsID);
            modelBuilder.Entity<Fees>().HasKey(x => x.FeesID);
            modelBuilder.Entity<Enquiries>().HasKey(x => x.EnquiryID);
            modelBuilder.Entity<EnquiryTypes>().HasKey(x => x.EnquiryTypeID);
            modelBuilder.Entity<TradingAddresses>().HasKey(x => x.TradingAddressID);
            modelBuilder.Entity<Salutations>().HasKey(x => x.Salutation);
            modelBuilder.Entity<Users>().HasKey(x => x.UserID);
            modelBuilder.Entity<CallCentres>().HasKey(x => x.CallCentreID);
            modelBuilder.Entity<LeadMonitor>().HasKey(x => x.LeadMonitorID);
            modelBuilder.Entity<BoilerLeads>().HasKey(x => x.BoilerLeadsID);
            modelBuilder.Entity<LeadTemplate>().HasKey(x => x.LeadTemplateID);
            modelBuilder.Entity<LeadStat>().HasKey(x => x.LeadStatID);
            modelBuilder.Entity<LeadStatQuestions>().HasKey(x => x.LeadStatQuestionsID);
            modelBuilder.Entity<LeadGroups>().HasKey(x => x.LeadGroupsID);
            modelBuilder.Entity<LeadGroupQuestions>().HasKey(x => x.LeadGroupQuestionsID);
            modelBuilder.Entity<CompanyRegistered>().HasKey(x => x.CompanyRegisteredID);
            modelBuilder.Entity<CompanySundries>().HasKey(x => x.CompanySundriesID);
            modelBuilder.Entity<CompanyRestrictions>().HasKey(x => x.CompanyRestrictionsID);
            modelBuilder.Entity<LeadResults>().HasKey(x => x.LeadResultsID);
            modelBuilder.Entity<ClientUsers>().HasKey(x => x.ClientUsersID);
            modelBuilder.Entity<LeadReasons>().HasKey(x => x.LeadReasonsID);
            modelBuilder.Entity<LeadFlags>().HasKey(x => x.LeadFlagsID);
            modelBuilder.Entity<LeadStatus>().HasKey(x => x.LeadStatusID);
            modelBuilder.Entity<PurchaseOrders>().HasKey(x => x.PurchaseOrderID);
            modelBuilder.Entity<LoadingCapacity>().HasKey(x => x.LoadingCapacityID);
            modelBuilder.Entity<Chasers>().HasKey(x => x.IntRef);
            modelBuilder.Entity<PostCodes>().HasKey(x => x.PostCodeID);
            modelBuilder.Entity<NextRef>().HasKey(x => x.LeadType);
            modelBuilder.Entity<Leads>().HasKey(x => x.LeadID);
            modelBuilder.Entity<UserFile>().HasKey(x => x.UserFileID);
            modelBuilder.Entity<ReferralCats>().HasKey(x => x.ReferralCatsID);
            modelBuilder.Entity<ReferralData>().HasKey(x => x.ReferralDataID);
            modelBuilder.Entity<QCOrder>().HasKey(x => x.leadstatusid);
            modelBuilder.Entity<ResetLockout>().HasKey(x => x.result);
            modelBuilder.Entity<RefreshPO>().HasKey(x => x.resultset);
            modelBuilder.Entity<Surveys>().HasKey(x => x.SurveyID);
            modelBuilder.Entity<SurveyMappings>().HasKey(x => x.SurveyMappingsID);
            modelBuilder.Entity<SurveyContacts>().HasKey(x => x.SurveyContactID);
            modelBuilder.Entity<SurveyCompletion>().HasKey(x => x.SurveyCompletionID);
            modelBuilder.Entity<ExportMappings>().HasKey(x => x.ExportMappingsID);
            modelBuilder.Entity<Countries>().HasKey(x => x.CountriesID);
            modelBuilder.Entity<Counties>().HasKey(x => x.CountiesID);
            modelBuilder.Entity<ExportData>().HasKey(x => x.ExportDataID);
            modelBuilder.Entity<ExportDataHistory>().HasKey(x => x.ExportDataHistoryID);
            modelBuilder.Entity<SurveyConstraints>().HasKey(x => x.SurveyConstraintsID);
            modelBuilder.Entity<SSC>().HasKey(x => x.sscID);
            
            base.OnModelCreating(modelBuilder); 
        }
    }
}